require(['./config'], () => {
    require(['template', 'header','footer'],(template)=>{
        class Index {
            constructor () {
                this.getListShop()
                this.getTabs()  
            }
            getTabs () {
                $.get('http://www.xiongmaoyouxuan.com/api/tab/10?start=0', resp => {
                    if(resp.code === 200){
                        let {categories} = resp.data
                        categories = categories.slice(2,9)
                        const html = template('giftListTab', {categories})
                        $('#ListTab').html(html)
                    }
                })
            }
            getListShop () {
                const id = location.search.slice(4)
                $.get(`http://www.xiongmaoyouxuan.com/api/category/${id}/items?start=0&sort=0`, resp => {
                    if(resp.code === 200){
                        const {list} = resp.data.items
                        const {cname} = resp.data.category
                        const html = template('giftListShop', {list})
                        $('#ListShop').html(html)
                    }
                })
            } 
        }
        new Index()
    })
})